package com.ayoka.parenting.ui.meditation.question;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.MeditationQuestionBean;
import com.ayoka.parenting.bean.ResponseMeditationQuestion;
import com.jincp.common.dialog.BaseDialogBuilder;
import com.jincp.common.dialog.BaseDialogFragment;

/**
 * =========================================================
 *
 * @ProjectName:
 * @ClassName: WhiteBoardDialog
 * @Description:
 * @Author: jincp
 * @CreateDate: 2019/9/19 16:18
 * =========================================================
 */
public class SynchronizedCircleGroupDialog extends BaseDialogFragment {

    public static SynchronizedCircleGroupDialog newInstance(Builder builder) {
        SynchronizedCircleGroupDialog dialog = new SynchronizedCircleGroupDialog();
        Bundle bundle = getArgumentBundle(builder);
        bundle.putString("Message", builder.message);
        dialog.setArguments(bundle);
        return dialog;
    }

    @Override
    protected void convertView(@Nullable final View container, final BaseDialogFragment dialogFragment) {
        if (getArguments() != null) {
            String message = getArguments().getString("Message");
            EditText editText = container.findViewById(R.id.edt_content);
            editText.setText(message);
            editText.setSelection(message.length());
        }
        container.findViewById(R.id.layout_not_synchronized).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mDialogResultListener != null) {
                    mDialogResultListener.result(SynchronizedCircleGroupDialog.this, false);
                }
            }
        });
        container.findViewById(R.id.layout_do_synchronized).setSelected(true);
        container.findViewById(R.id.tv_do_synchronized).setSelected(true);
        container.findViewById(R.id.layout_do_synchronized).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mDialogResultListener != null) {
                    mDialogResultListener.result(SynchronizedCircleGroupDialog.this, true);
                }
            }
        });

    }

    @Override
    protected int getLayoutId() {
        return R.layout.dialog_synchronized_circle_group;
    }

    public static class Builder extends BaseDialogBuilder<Builder, SynchronizedCircleGroupDialog> {

        private String message;

        public Builder setMessage(String content) {
            this.message = content;
            return this;
        }

        @Override
        public SynchronizedCircleGroupDialog build() {
            return SynchronizedCircleGroupDialog.newInstance(this);
        }
    }
}